 <!DOCTYPE html>
 <html lang="en">
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
 </head>
 <body>
   
  <script>
    // ES5中如何定义类
    // function Person(name, age) {
    //   this.name = name
    //   this.age = age
    // }

    // Person.prototype.runing = function() {
    //   console.log(this.name, this.age, 'runing')
    // }

    // var p = new Person('name', 'age')
    // console.log(p.name, p.age)
    // p.runing()

    // ES6中如何定义类
    class Person {
      constructor(name, age) {
        this.name = name
        this.age = age
      }

      runing() {
        console.log(this.name, this.age, 'runing')
      }
    }

    const p = new Person('mei', 10)
    p.runing()

    let func = p.runing;
    // func();
    var obj = {
      name: 'xia',
      age: 20
    }

    // func.apply 
    func.call(obj)

    func = func.bind(obj)
    func()

  </script>
 </body>
 </html>